import mongoose from 'mongoose';
mongoose.connect('mongodb://localhost/rcdb');

mongoose.connection.on('error', err => {
    console.error(err);
});

const Model = {
    Schema: mongoose.Schema,
    schema: {},
    define(name, schemaJson) {
        let schema = new mongoose.Schema(schemaJson);
        Model[name] = mongoose.model(name, schema);
        Model.schema[name] = schema;
    }
};

export default Model;
